import openpyxl
import pandas as pd



for index, row in df.iterrows():
    region = row['省(市)']
    if region in region_counts:
        region_counts[region] += 1
    else:
        region_counts[region] = 1

for region, count in region_counts.items():
    print(f"省(市): {region}, 商户数量: {count}")

def save_to_excel_sheet(data,wb,file):
    #wb = Workbook(path_excel)
    writer = pd.excelwriter('20240121.xlsx')
    writer.book = wb
    data.to_excel(writer,sheet_name='new')
    writer.save()
    writer.close()


if __name__ == '__main__':
    workbook = openpyxl.load_workbook('20240121.xlsx')
    # 打开excel
    worksheet = workbook.create_sheet('new')
    # 在现有excel新增newsheet
    workbook.save('20240121.xlsx')
    # 保存newsheet在现有excel
    df = pd.read_excel('20240121.xlsx',sheet_name='商户每日交易信息汇总表',header=2,usecols='A:S')
    #查找excel中的sheet


    region_counts = {}